<template>
  <div id="carousel">
    <el-carousel
      :interval="4000"
      type="card"
      height="320px"
      @click="play"
    >
      <el-carousel-item
        v-for="(item,index) in carouselist"
        :key="index"
      >
        <img
          :src="item.imageUrl"
          alt=""
        >
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
// 引入axios组件
import axios from "axios";
export default {
  name: "carousel",
  data() {
    return {
      // 存区导航图片的数组
      //  "https://www.jianfast.com/static/home/images/bg/s/bg001.jpg",
      //   "https://www.jianfast.com/static/home/images/bg/s/bg002.jpg",
      //   "https://www.jianfast.com/static/home/images/bg/s/bg006.jpg",
      //   "https://www.jianfast.com/static/home/images/bg/s/bg007.jpg"
      carouselist: []
    };
  },
  created() {
    axios({
      url: "https://autumnfish.cn/banner",
      method: "get"
    }).then(res => {
      // console.log(res)
      this.carouselist = res.data.banners;
    });
  },
  methods: {
    play() {
      console.log("play");
    }
  }
};
</script>

<style lang="scss">
#carousel {
  padding: 0px 6%;
  border-radius: 10px;
}
.el-carousel__item {
  border-radius: 10px;
  h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 200px;
    margin: 0;
  }
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
// #carousel .el-carousel
#carousel .el-carousel img {
  width: 100%;
  height: 320px;
}
.el-carousel__button {
  height: 7px;
  width: 40px;
}
</style>